package com.gzsxy.excel.dropDownListHandler;

import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationConstraint;
import org.apache.poi.ss.usermodel.DataValidationHelper;
import org.apache.poi.ss.util.CellRangeAddressList;

/**
 * @Author
 * @Description //TODO Excel模板对象
 * @Date 2022/01/14
 * @Param $
 * @return $
 **/

public class TeamUserSheetWriteHandler implements SheetWriteHandler {

    @Override
    public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
        CellRangeAddressList list1 = new CellRangeAddressList(1, 1000, 1, 1); //1到1000行、2到3列添加下拉框
        DataValidationHelper helper1 = writeSheetHolder.getSheet().getDataValidationHelper();
        DataValidationConstraint constraint1 = helper1.createExplicitListConstraint(new String[]{"成员","负责人"});
        DataValidation dataValidation = helper1.createValidation(constraint1, list1);
        writeSheetHolder.getSheet().addValidationData(dataValidation);
    }
}